<template>
	<view class="bgColor" style="background-color: #fff;overflow: hidden;">
		<!-- <nacBer>
		</nacBer> -->
		<view  @click="gotoHome" style="position: absolute; left: 20rpx;top: 60rpx;z-index: 9999;">
			<u-icon name="home" color="#2979ff" size="28"></u-icon>
		</view>
		<view class="bold">注册</view>
		<view class="describe">请告诉我们，您的手机号码</view>
		<view class="from_box">
			<u--form
				labelPosition="left"
				:model="userInfo"
				:rules="rules"
				ref="uForm"
			>
				<u-form-item
					prop="name"
					borderBottom
				>
				 <view class="userInfro_flex">
					 <view class="ico_right_10">
						 <u-icon name="phone" color="#2979ff" size="28"></u-icon>
					 </view>
					 <u--input
						v-model="userInfo.name"
						maxlength="11"
						type="number"
						border="none"
						placeholder="请输入手机号"
					 ></u--input>
				 </view>
				</u-form-item>
			</u--form>
		</view>
		<view class="login_top_100">
			<u-button @click="nextFun" type="primary">下一步</u-button>
		</view>
	</view>
</template>

<script>
	import nacBer from '@/components/navBar/index'
	export default {
		data() {
			return {
				userInfo: {
					name: ''
				},
				agencyId: '',
				userType: '',
				rules: {
					name: {
						type: 'string',
						required: true,
						message: '请输入手机号',
						trigger: ['blur']
					},
				},
			}
		},
		components: {
			nacBer
		},
		onLoad(option) {
			// console.log('fasd214123512', option)
			// console.log('fasd214123512', option.q)
			// console.log('fasd214123512', this.GetRequest(decodeURIComponent(option.q)))
			
			this.userType = option.userType
			if (option.q) {
				let datas = this.GetRequest(decodeURIComponent(option.q))
				this.userType = '02'
				this.agencyId = datas.agencyId
			}
			
		},
		methods: {
			gotoHome() {
				uni.reLaunch({
					url:'/pages/login/index'
				});
			},
			GetRequest(params) {
			    let url = params.substring(params.indexOf("?")); //获取url中"?"符后的字串
			    let theRequest = new Object();
			    if (url.indexOf("?") != -1) {
			        let str = url.substr(1);
			        let strs = str.split("&");
			        for (let i = 0; i < strs.length; i++) {
			            theRequest[strs[i].split("=")[0]] = unescape(strs[i].split("=")[1]);
			        }
			    }
			    return theRequest;
			},
			nextFun() {
				console.log(this.agencyId)
				this.$refs.uForm.validate().then(res => {
					// uni.navigateTo({
					// 	url: "/pages/register/code/index"
					// })
					uni.navigateTo({
						url: `/pages/register/setPassword/index?userType=${this.userType}&userName=${this.userInfo.name}${this.agencyId? `&agencyId=${this.agencyId}` : ``}`
					})
				}).catch(errors => {
					uni.$u.toast('校验失败')
				})
				// this.$refs.uForm.validate().then(res => {
				
				// }).catch(errors => {
				// 	uni.$u.toast('校验失败')
				// })
			},
		}
	}
</script>

<style lang="scss" scoped>
	.from_box {
		width: 100%;
		padding: 0 60rpx;
		box-sizing: border-box;
	}
	.userInfro_flex {
		display: flex;
	}
	.login_top_100 {
		border-radius: 100rpx;
		width: 550rpx;
		overflow: hidden;
		margin: auto;
		margin-top: 20%;
	}
	.bold {
		font-size: 50rpx;
		font-weight: bold;
		margin: 50rpx 0 30rpx 50rpx;
		margin-top: 190rpx;
	}
	.describe {
		margin-left: 50rpx;
		margin-bottom: 100rpx;
	}
	.ico_right_10 {
		margin-right: 30rpx;
	}
</style>